package com.miyue.stepdemo

import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import android.view.ViewGroup
import android.widget.Button
import android.widget.LinearLayout
import android.widget.TextView
import androidx.core.view.marginBottom

class MainActivity : AppCompatActivity() {
    private lateinit var step1 : StepView
    private lateinit var step2 : StepView
    private lateinit var step3 : StepView
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        step1 = findViewById(R.id.step1)
        step1.setOnClickListener {
            step1.updateSelectedStyle()
            step2.updateNotSelectedStyle()
            step3.updateNotSelectedStyle()
        }
        step2 = findViewById(R.id.step2)
        step2.setOnClickListener {
            step1.updateNotSelectedStyle()
            step2.updateSelectedStyle()
            step3.updateNotSelectedStyle()
        }
        step3 = findViewById(R.id.step3)
        step3.setOnClickListener {
            step1.updateNotSelectedStyle()
            step2.updateNotSelectedStyle()
            step3.updateSelectedStyle()
        }

        val step11 = StepView(this)
        step11.setStyle(StepView.STYLE_SELECTED)
        step11.setType(StepView.TYPE_START)
        step11.setText("第一步")
        step11.setTextSize(30f)

        val step22 = StepView(this)
        step22.setStyle(StepView.STYLE_SELECTED)
        step22.setType(StepView.TYPE_MIDDLE)
        step22.setText("第二步")
        step22.setTextSize(30f)

        val step33 = StepView(this)
        step33.setStyle(StepView.STYLE_SELECTED)
        step33.setType(StepView.TYPE_STOP)
        step33.setText("第三步")
        step33.setTextSize(30f)
        val linearLayout = findViewById<LinearLayout>(R.id.ll_step2)
        linearLayout.addView(step11)
        linearLayout.addView(step22)
        linearLayout.addView(step33)

        findViewById<Button>(R.id.bt_compose).setOnClickListener {
            startActivity(Intent(this,StepComposeView::class.java))
        }
    }
}